<div
    bsModal
    #createOrEditModal="bs-modal"
    class="modal fade"
    tabindex="-1"
    role="dialog"
    aria-labelledby="createOrEditModal"
    aria-hidden="true"
    [config]="{ backdrop: 'static' }"
>
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form
                *ngIf="active"
                #editForm="ngForm"
                novalidate
                (ngSubmit)="save()"
                autocomplete="off"
            >
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span>编辑人员工时</span>
                    </h4>
                    <button
                        type="button"
                        class="close"
                        (click)="close()"
                        [attr.aria-label]="l('Close')"
                    >
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>

                <div class="modal-body">
                    <div class="row" [busyIf]="primengTableHelper.isLoading">
                        <div class="col-md-12" style="margin-bottom: 20px;">
                            <span>任务号：{{ proc.taskCode }}</span>
                            <span style="margin-left: 35px;"
                                >图号：{{ proc.drawingNum }}</span
                            >
                            <span style="margin-left: 35px;"
                                >质控卡：{{ proc.zhiKongKaCode }}</span
                            >
                            <span style="margin-left: 35px;"
                                >工序名称：{{ proc.nodeName }}</span
                            >
                        </div>
                        <div class="col-md-12">
                                <p-table
                                [value]="nodeWorker"
                                [paginator]="true"
                                [rows]="5"
                                class="gxzxu"
                              >
                                <ng-template pTemplate="caption"> 人员及工时分配 </ng-template>
                                <ng-template pTemplate="header">
                                  <tr>
                                    <th
                                      style="
                                        width: 2em;
                                        border-left: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    ></th>
                                    <th
                                      style="
                                        height: 40px;
                                        border-right: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    >
                                      人员姓名
                                    </th>
                                    <th
                                      style="
                                        height: 40px;
                                        border-right: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    >
                                      分配工时
                                    </th>
                                    <th
                                      style="
                                        height: 40px;
                                        border-right: 1px solid #cdcdcd;
                                        width: 5em;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    >
                                      操作
                                    </th>
                                  </tr>
                                </ng-template>
                                <ng-template pTemplate="body" let-rowData let-ri="rowIndex">
                                  <tr>
                                    <td
                                      style="
                                        height: 36px;
                                        border-left: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    ></td>
                                    <td
                                      pEditableColumn
                                      style="
                                        border-right: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    >
                                      <p-cellEditor>
                                        <ng-template pTemplate="input">
                                          <p-dropdown
                                            [options]="users"
                                            [(ngModel)]="rowData.userName"
                                            [style]="{ width: '100%' }"
                                            optionLabel="name"
                                            [filter]="true"
                                            [showClear]="true"
                                            name="userName"
                                          ></p-dropdown>
                                        </ng-template>
                                        <ng-template pTemplate="output">
                                          {{ rowData.userName.name }}
                                        </ng-template>
                                      </p-cellEditor>
                                    </td>
                                    <td
                                      pEditableColumn
                                      style="
                                        border-right: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    >
                                      <p-cellEditor>
                                        <ng-template pTemplate="input">
                                          <p-spinner
                                            size="55"
                                            [step]="0.25"
                                            (keyup)="jisuan()"
                                            [(ngModel)]="rowData.personWorkingTime"
                                            [min]="0"
                                            name="personWorkingTime"
                                            [inputStyle]="{
                                              width: '300px'
                                            }"
                                          ></p-spinner>
                                        </ng-template>
                                        <ng-template pTemplate="output">
                                          {{ rowData.personWorkingTime }}
                                        </ng-template>
                                      </p-cellEditor>
                                    </td>
                                    <td
                                      style="
                                        border-right: 1px solid #cdcdcd;
                                        border-bottom: 1px solid #cdcdcd;
                                      "
                                    >
                                      <button
                                        pButton
                                        type="button"
                                        pInitEditbaleRow
                                        icon="pi pi-times"
                                        class="ui-button-danger"
                                        (click)="onRowEditInit(ri)"
                                      ></button>
                                    </td>
                                  </tr>
                                </ng-template>
                                <ng-template pTemplate="summary" let-rowData>
                                  <div style="text-align: left">
                                    <button
                                      type="button"
                                      pButton
                                      icon="fa fa-plus"
                                      (click)="showDialogToAdd()"
                                      label="新增"
                                    ></button>
                                    <button
                                      type="button"
                                      pButton
                                      icon="fa fa-save"
                                      (click)="save()"
                                      label="保存"
                                      
                                      style="
                                        margin-left: 15px;
                                        background-color: #34bfa3;
                                        border: solid 1px #34bfa3;
                                      "
                                    ></button>
                                  </div>
                                </ng-template>
                              </p-table>
                        </div>
                        <div
                            class="col-md-12"
                            style="margin-top: 15px; font-weight: bold;"
                        >
                            <span
                                >当前工序总工时：{{
                                    proc.totalProcWorkingTime
                                }}</span
                            >
                            <span style="margin-left: 15px;"
                                >当前已分配工时：{{
                                    total + userworkingtime
                                }}</span
                            >
                            <span style="margin-left: 15px;"
                                >当前剩余工时：{{
                                    proc.totalProcWorkingTime-(total + userworkingtime)
                                }}</span
                            >
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button
                        [disabled]="saving"
                        type="button"
                        class="btn btn-default"
                        (click)="close()"
                    >
                        {{ l('Cancel') }}
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
